package com.hub.utils.enums;

import com.hub.utils.KeyValueModel;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public enum SupplierTypeEnum {

    AssetSupplier(1,"资产供应商"),
    PartsSupperlier(2,"备件供应商");

    private int code;
    private String description;

    SupplierTypeEnum(int code,String description){
        this.code = code;
        this.description = description;
    }

    /**
     * 获取枚举值的描述
     * @param index
     * @return
     */
    public static String getDescription(int index) {
        for(SupplierTypeEnum stEnum : SupplierTypeEnum.values()){
            if(stEnum.getCode() == index){
                return stEnum.description;
            }
        }
        return "未知编码";
    }

    /**
     * 获取枚举Code-Description
     * @return
     */
    public static List<KeyValueModel> getMaps()
    {
        List<KeyValueModel> list = new ArrayList();
        for(SupplierTypeEnum stEnum : SupplierTypeEnum.values()){
            KeyValueModel kv = new KeyValueModel();
            kv.setKey(stEnum.getCode());
            kv.setValue(stEnum.description);
            list.add(kv);
        }

        return list;
    }
}
